home *** CD-ROM | disk | FTP | other *** search
- --------------------------------------------------------------------------------
- -- Weapon Airstrike + Projectile Cluster
- -- Original Carnage Contest Weapon
- -- Script by DC, August 2009, www.UnrealSoftware.de
- --------------------------------------------------------------------------------
-
- -- Setup Tables
- if cc==nil then cc={} end
- cc.airstrike={}
- cc.airstrike.cluster={}
-
- -- Load & Prepare Ressources
- cc.airstrike.gfx_wpn=loadgfx("weapons/rc.bmp") -- Weapon Image
- setmidhandle(cc.airstrike.gfx_wpn)
- cc.airstrike.gfx_icon=loadgfx("weapons/airstrikeicon.png") -- Weapon Icon
- setmidhandle(cc.airstrike.gfx_icon)
- cc.airstrike.gfx_pro=loadgfx("weapons/cluster.bmp") -- Projectile Image
- setmidhandle(cc.airstrike.gfx_pro)
- cc.airstrike.sfx_attack=loadsfx("airstrike.ogg") -- Attack Sound
-
- --------------------------------------------------------------------------------
- -- Weapon: Airstrike
- --------------------------------------------------------------------------------
-
- cc.airstrike.id=addweapon("cc.airstrike","Air Strike",cc.airstrike.gfx_icon,1,2) -- Add Weapon (1 use, first in round 2)
-
- function cc.airstrike.draw() -- Draw
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- drawinhand(cc.airstrike.gfx_wpn,7,0)
- -- HUD Positioning
- if weapon_shots==0 then
- hudpositioning(pos_invisible)
- end
- end
-
- function cc.airstrike.attack(attack) -- Attack
- if (weapon_shots<=0) and (weapon_position==1) then
- -- No more weapon switching!
- useweapon(0)
- playsound(cc.airstrike.sfx_attack)
- weapon_shots=weapon_shots+1
- -- Attack
- for i=-2,2,1 do
- pid=createprojectile(cc.airstrike.cluster.id)
- projectiles[pid]={}
- projectiles[pid].x=weapon_x+(i*15)
- projectiles[pid].y=-500
- projectiles[pid].sx=0
- projectiles[pid].sy=3.0
- if i==0 then projectiles[pid].follow=1 end
- end
- -- End Turn
- endturn()
- end
- end
-
- --------------------------------------------------------------------------------
- -- Projectile: Cluster
- --------------------------------------------------------------------------------
-
- cc.airstrike.cluster.id=addprojectile("cc.airstrike.cluster") -- Add Projectile
-
- function cc.airstrike.cluster.draw(id) -- Draw
- -- Setup draw mode
- setblend(blend_alpha)
- setalpha(1)
- setcolor(255,255,255)
- setscale(1,1)
- -- Calculate projectile rotation
- setrotation(math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy)))
- -- Draw projectile
- drawimage(cc.airstrike.gfx_pro,projectiles[id].x,projectiles[id].y)
- end
-
- function cc.airstrike.cluster.update(id) -- Update
- rot=math.deg(math.atan2(projectiles[id].sx,-projectiles[id].sy))
- -- Particle Tail
- particle(p_smoke,projectiles[id].x-math.sin(math.rad(rot))*7,projectiles[id].y+math.cos(math.rad(rot))*7)
- particlespeed(math.random(-2,2)*0.1,math.random(-2,2)*0.1)
- particlefadealpha(0.05)
- -- Wind + Gravity influence on speed
- projectiles[id].sx=projectiles[id].sx+getwind()*0.3
- projectiles[id].sy=projectiles[id].sy+getgravity()
- -- Move (in substep loop for optimal collision precision)
- msubt=math.ceil(math.max(math.abs(projectiles[id].sx),math.abs(projectiles[id].sy))/3)
- msubx=projectiles[id].sx/msubt
- msuby=projectiles[id].sy/msubt
- for i=1,msubt,1 do
- projectiles[id].x=projectiles[id].x+msubx
- projectiles[id].y=projectiles[id].y+msuby
- -- Collision
- if collision(col3x3,projectiles[id].x,projectiles[id].y)==1 then
- -- Cause damage
- arealdamage(projectiles[id].x,projectiles[id].y,70,25)
- -- Destroy terrain
- terrainexplosion(projectiles[id].x,projectiles[id].y,15,1)
- -- Crater
- grey=math.random(0,40)
- terrainalphaimage(gfx_crater75,projectiles[id].x,projectiles[id].y,math.random(5,7)*0.1,grey,grey,grey)
- -- Free projectile
- freeprojectile(id)
- break
- end
- -- Water
- if (projectiles[id].y)>getwatery()+5 then
- -- Effects
- particle(p_waterhit,projectiles[id].x,projectiles[id].y)
- playsound(sfx_hitwater1)
- -- Free projectile
- freeprojectile(id)
- break
- end
- end
- -- Scroll to projectile
- if projectiles[id].follow==1 then
- scroll(projectiles[id].x,projectiles[id].y)
- end
- end